package com.xiaoshu.controller;

import com.xiaoshu.model.ResultVo;
import com.xiaoshu.service.feign.FileFeignImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 功能说明： 文件上传服务，提供文件服务操作
 *
 * @ com.xiaoshu.service.controller
 * <p>
 * Original @Author: deane.jia-贾亮亮,@2020/10/28@10:19
 * <p>
 * Copyright (C)2012-@2020 深圳小树盛凯科技 All rights reserved.
 */
@RestController
@RequestMapping(value = "/consumer/file")
@Slf4j
@Api(value = "文件管理")
public class FileController {

    @Autowired
    FileFeignImpl fileFeign;

    /**
     * @param file
     * @return
     */
    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    @ApiOperation(value = "上传文件")
    public ResultVo<?> uploadFile(@ApiParam(value = "file") @RequestParam(value = "file") MultipartFile file) {
        log.info("Consumer upload the file , file name is :{}", file.getName());
        return fileFeign.uploadFileService(file);
    }
}
